package views;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.wb.swt.SWTResourceManager;

public class TeremOnUiView extends Composite {

	Label lblTeremnv;
	Label lblDtum;
	Composite idoVonal;

	public TeremOnUiView(Composite arg0, int arg1) {
		super(arg0, arg1);
		setContent();
	}

	private void setContent() {
		GridLayout gd_main = new GridLayout();
		this.setLayout(gd_main);

		lblTeremnv = new Label(this, SWT.NONE);
		lblTeremnv.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true,
				false, 1, 1));
		lblTeremnv.setAlignment(SWT.CENTER);
		lblTeremnv.setFont(SWTResourceManager.getFont("Times New Roman", 10,
				SWT.BOLD));
		lblTeremnv.setText("Teremn\u00E9v");

		lblDtum = new Label(this, SWT.NONE);
		lblDtum.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false,
				1, 1));
		lblDtum.setFont(SWTResourceManager.getFont("Times New Roman", 10,
				SWT.BOLD));
		lblDtum.setText("D\u00E1tum");

		idoVonal = new Composite(this, SWT.NONE);
		idoVonal.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1,
				1));

		idoVonal.addPaintListener(new PaintListener() {

			@Override
			public void paintControl(PaintEvent e) {
				Rectangle clientArea = idoVonal.getClientArea();
				int startPointText = (int) Math.round(clientArea.width
						* new Double("0.03"));
				int height = Math.round((clientArea.height - 2) / 14f);
				for (int i = 0; i < 14; i++) {
					if (i % 2 == 0) {
						e.gc.setBackground(SWTStaticObjects.TIMELINE_COLOR_1);
					} else {
						e.gc.setBackground(SWTStaticObjects.TIMELINE_COLOR_2);
					}
					e.gc.fillRectangle(0, i * height, clientArea.width, height);
					e.gc.setFont(SWTResourceManager.getFont("Times New Roman",
							9, SWT.NONE));
					e.gc.drawText((6 + i) + ":00 - " + (7 + i) + ":00",
							startPointText, (i * height) + (height / 2 - 5));
				}

			}
		});
	}

	public Label getLblTeremnv() {
		return lblTeremnv;
	}

	public Label getLblDtum() {
		return lblDtum;
	}

	public Composite getIdoVonal() {
		return idoVonal;
	}

}
